#define aplf(...) { char tmps[300]; sprintf(tmps,__VA_ARGS__); apl(tmps); }
#define pf(...) { char tmps[300]; sprintf(tmps,__VA_ARGS__); pl(tmps); }
#define RGBA( r, g, b, a ) ( (r<<24) | (g<<16) | (b<<8) | a )
#define ARGB( r, g, b, a ) ( (a<<24) | (r<<16) | (g<<8) | b )
#define ABGR( r, g, b, a ) ( (a<<24) | (b<<16) | (g<<8) | r )
#define sok() fcolor(ABGR(0,255,0,255)); apl(" OK! \n");
#define sfail() fcolor(ABGR(255,0,0,255)); apl(" ERR \n");



void screeninit() { pspDebugScreenInit(); }
void pc(unsigned char c) { char temp[2]; sprintf(temp,"%c",c); pspDebugScreenPrintf(temp); }
void fcolor(int color) { pspDebugScreenSetTextColor(color); }
void bcolor(int color) { pspDebugScreenSetBackColor(color); }
void cls() { pspDebugScreenClear(); }
void sxy(int x, int y) { pspDebugScreenSetXY(x,y); }
int gx() { return pspDebugScreenGetX(); }
int gy() { return pspDebugScreenGetY(); }

void pl(char *str) {
	int i;
	for (i=0;i<strlen(str);i++)
		pc(str[i]);
}

void appkilled() {
	bcolor(0xFF000000); fcolor(0xFFFFFFFF); fcolor(ABGR(255,0,0,255)); pf("\n[!] "); fcolor(ABGR(255,255,255,255)); pf("Presiona X para volver al XMB.");
	while (1) {
		sceCtrlReadBufferPositive(&pad,1);
		if ( pad.Buttons & PSP_CTRL_CROSS ) { sceKernelExitGame(); break; } 
		if ( pad.Buttons & PSP_CTRL_CIRCLE ) { sceKernelExitGame(); } 
	}	
}


void zzz(int numframes) { 
	int i; 
	for (i=1;i<=numframes;i++) { 
		SceCtrlData pad; 
		sceCtrlReadBufferPositive(&pad,1); 
	} 
}

void apl(char *str) { 
	int i; 
	for (i=0;i<strlen(str);i++) { 
		pc(str[i]); 
		zzz(1); 
	} 
}

